
package com.tfswue.hql.controller;

import com.tfswue.hql.config.MyProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloController {

    @Value("${app.email}")
    private String email;

    // 修复city1的引用路径并解注释
    @Value("${app.city1[0]}")
    private String city1;

    private final MyProperties myProperties;

    public HelloController(MyProperties myProperties) {
        this.myProperties = myProperties;
    }

    // 修复sxt的引用路径并解注释
    @Value("${app.sxt[0].mobile}")
    private String mobile;

    @GetMapping("/hello")
    public String hello() {
        return "你好，欢迎来到Spring Boot世界！";
    }

    // 实现完整的getvalue方法并解注释
    @GetMapping("/getvalue")
    public String getValue() {
        return "邮件："+email + " | 城市: " + city1 + " | 手机: " + mobile;
    }

    @GetMapping("/email")
    public String email() {
        return email;
    }

    @GetMapping("/my-config")
    public String showConfig() {
        return String.format("My1: %s/%s | My2: %s/%s",
                myProperties.getMy1().getEmail(),
                myProperties.getMy1().getPassword(),
                myProperties.getMy2().getEmail(),
                myProperties.getMy2().getPassword());
    }
}